import { createApp } from 'vue';
import App from './App';
import Router from './router';

import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';

import GctCore from '@gct-paas/core';
import GctCoreMobile from '@gct-paas/core-mobile';
import GctCoreWeb from '@gct-paas/core-web';
import GctDesign from '@gct-paas/design';

import DesignView from '@gct-paas/design-view';

import { web, mobile } from '@gct-paas/plugin-design';
import MobileComponent from '@gct-paas/plugin-mobile';
import WebComponent from '@gct-paas/plugin-web';

GctCore();
GctDesign();

async function run(): Promise<void> {
  const app = createApp(App);

  app.use(Router);

  app.use(Antd);

  app.use(GctCoreMobile);
  app.use(GctCoreWeb);
  app.use(DesignView);

  const pkg = import.meta.env.PKG;

  _gct.register.designer.web.register(pkg.name, () => new web());
  _gct.register.designer.mobile.register(pkg.name, () => new mobile());

  _gct.register.render.mobile.register(pkg.name, MobileComponent);
  _gct.register.render.web.register(pkg.name, WebComponent);

  app.mount('#app');
}

run();
